<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="auto">

            <el-form-item label="状态" prop="status">
                <el-select v-model="queryParams.status" placeholder="请选择数据状态" clearable size="small">
                    <el-option
                        v-for="item in [{label:'待审核', value: 0},{label:'已通过', value: 1},{label:'未通过', value: 2}]"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                    ></el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="开始时间" prop="start_createTime">
                <el-date-picker
                    clearable
                    v-model="queryParams.start_createTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="开始日期">
                </el-date-picker>
            </el-form-item>

            <el-form-item label="结束时间" prop="end_createTime">
                <el-date-picker
                    clearable
                    v-model="queryParams.end_createTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="结束日期">
                </el-date-picker>
            </el-form-item>

            <el-form-item label="创建人" prop="createUserId" v-if="createUserList.length > 0">
                <el-select v-model="queryParams.createUserId" placeholder="请选择创建人" clearable size="small">
                    <el-option
                        v-for="item in createUserList"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                    ></el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="创建部门" prop="createDeptId" v-if="createDeptList.length > 0">
                <el-select v-model="queryParams.createDeptId" placeholder="请选择创建部门" clearable size="small">
                    <el-option
                        v-for="item in createDeptList"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                    ></el-option>
                </el-select>
            </el-form-item>

            <el-form-item :label="item.nameZh" :prop="item.nameEn" v-for="(item,i) in selectFieldList">
                <component
                    :is="item.fieldType"
                    :pData="item"
                    ref="queryComponentRef"
                    @queryFormChangeVal="queryFormChangeVal">
                </component>
            </el-form-item>


            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>

        </el-form>

        <el-row :gutter="10" class="mb8">

            <el-col :span="1.5">
                <el-button
                    type="primary"
                    plain
                    icon="el-icon-plus"
                    size="mini"
                    @click="handleAdd"
                    v-hasPermi="['system:dynamic:add']"
                >新增
                </el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button
                    type="success"
                    plain
                    icon="el-icon-edit"
                    size="mini"
                    :disabled="single"
                    @click="handleUpdate"
                    v-hasPermi="['system:dynamic:edit']"
                >修改
                </el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button
                    type="danger"
                    plain
                    icon="el-icon-delete"
                    size="mini"
                    :disabled="multiple"
                    @click="handleDelete"
                    v-hasPermi="['system:dynamic:remove']"
                >删除
                </el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button
                    type="primary"
                    plain
                    icon="el-icon-s-check"
                    size="mini"
                    :disabled="multiple"
                    @click="handleAudit"
                    v-hasPermi="['system:dynamic:audit']"
                >审核
                </el-button>
            </el-col>
            <!--      <el-col :span="1.5">-->
            <!--        <el-button-->
            <!--          type="warning"-->
            <!--          plain-->
            <!--          icon="el-icon-download"-->
            <!--          size="mini"-->
            <!--          :loading="exportLoading"-->
            <!--          @click="handleExport"-->
            <!--          v-hasPermi="['system:dynamic:export']"-->
            <!--        >导出-->
            <!--        </el-button>-->
            <!--      </el-col>-->
            <el-col :span="1.5">
                <el-button
                    type="primary"
                    plain
                    icon="el-icon-view"
                    size="mini"
                    :disabled="multiple"
                    :loading="releaseLoading"
                    @click="handleRelease"
                    v-hasPermi="['system:dynamic:release']"
                >发布
                </el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button
                    type="danger"
                    plain
                    icon="el-icon-remove"
                    size="mini"
                    :disabled="multiple"
                    @click="handleWithdraw"
                    v-hasPermi="['system:dynamic:withdraw']"
                >下撤
                </el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button
                    type="primary"
                    plain
                    icon="el-icon-view"
                    size="mini"
                    :loading="releaseLoading"
                    @click="handleReleaseAll"
                    v-hasPermi="['system:dynamic:release']"
                >全库发布
                </el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button
                    type="primary"
                    plain
                    icon="el-icon-refresh"
                    size="mini"
                    :loading="releaseLoading"
                    @click="handleFlushesAllCaches"
                >刷新缓存
                </el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button
                    type="primary"
                    plain
                    icon="el-icon-help"
                    size="mini"
                    @click="toDataProperty"
                    v-hasPermi="['system:dataProperty:list']"
                >前往字段管理
                </el-button>
            </el-col>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
        <el-table v-loading="loading" :data="dynamicDataList" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" align="center"/>
            <el-table-column label="序号" type="index" width="50"></el-table-column>
            <el-table-column label="资源ID" width="150" align="center" prop="id"/>
            <el-table-column :label="item.nameZh" align="center" :prop="item.nameEn" v-for="(item,i) in showFieldList">
                <template #default="scope" v-if="item.dataTypeName == 'imgPath'">
                    <el-image class="table-td-thumb" :src="imgPathBase+scope.row[item.nameEn]"
                              :preview-src-list="[imgPathBase+scope.row[item.nameEn]]">
                    </el-image>
                </template>
                <template #default="scope" v-else-if="item.dataTypeName == 'selectSingle' || item.dataTypeName == 'selectMultiple'">
                   {{scope.row[item.nameEn] | getDictLabel(item.dictType.dictDataList)}}
                </template>
            </el-table-column>

            <el-table-column label="创建时间" width="150" align="center" prop="create_time"/>
            <el-table-column label="创建人" width="80" align="center" prop="create_user_name"/>
            <el-table-column label="创建部门" width="80" align="center" prop="create_dept_name"/>
            <el-table-column label="状态" width="80" align="center" prop="status">
                <template slot-scope="scope">
                    <el-tag type="info" v-if="scope.row.status == 0">待审核</el-tag>
                    <el-tag type="success" v-else-if="scope.row.status == 1">已通过</el-tag>
                    <el-tag type="danger" v-else>未通过</el-tag>
                </template>
            </el-table-column>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
                <template slot-scope="scope">
                    <el-button
                        v-if="scope.row.status == 2"
                        size="mini"
                        type="text"
                        icon="el-icon-chat-dot-round"
                        @click="handleAuditDetail(scope.row)"
                        v-hasPermi="['system:dynamic:list']"
                    >拒绝理由
                    </el-button>
                    <el-button
                        v-if="scope.row.status == 0"
                        size="mini"
                        type="text"
                        icon="el-icon-s-check"
                        @click="handleAudit(scope.row)"
                        v-hasPermi="['system:dynamic:audit']"
                    >审核
                    </el-button>
                    <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-edit"
                        @click="handleUpdate(scope.row)"
                        v-hasPermi="['system:dynamic:edit']"
                    >修改
                    </el-button>
                    <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-delete"
                        @click="handleDelete(scope.row)"
                        v-hasPermi="['system:dynamic:remove']"
                    >删除
                    </el-button>
                    <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-view"
                        @click="handleRelease(scope.row)"
                        v-hasPermi="['system:dynamic:release']"
                    >发布
                    </el-button>
                    <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-remove"
                        @click="handleWithdraw(scope.row)"
                        v-hasPermi="['system:dynamic:withdraw']"
                    >下撤
                    </el-button>
                    <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-attract"
                        @click="handleAssociate(scope.row)"
                        v-if="checkPermi(['system:dynamic:associate']) && objectPropertyListCount > 0"
                    >关联属性
                    </el-button>
                    <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-refresh"
                        @click="handleFlushesSingleCache(scope.row)"
                    >刷新缓存
                    </el-button>
                    <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-circle-plus-outline"
                        @click="copyOne(scope.row)"
                    >复制
                    </el-button>
                </template>
            </el-table-column>
        </el-table>

        <pagination
            v-show="total>0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
        />

        <!-- 添加或修改公共基础字段对话框 -->
        <el-dialog :title="title" :visible.sync="open" width="80%" :close-on-click-modal="false" append-to-body>
            <el-form ref="form" :model="form" :rules="rules" label-width="auto" label-position="top">
                <div v-for="(item,i) in showFieldDetail" :class="[(item.fieldType == 'multiple' || item.fieldType == 'richText'
        || item.fieldType == 'imgPath' || item.fieldType == 'filePath')?'col-md-12':'col-lg-6']">
                    <el-form-item :label="item.nameZh" :prop="item.nameEn">
                        <!-- 此处的v-if 是为了重新渲染组件。设置wangEditor的内容 -->
                        <component :is="item.fieldType" :pData="item" @formChangeVal="formChangeVal"
                                   v-if="open"></component>
                    </el-form-item>
                </div>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitForm">确 定</el-button>
                <el-button @click="cancel">取 消</el-button>
            </div>
        </el-dialog>


        <el-dialog title="关联属性管理" :visible.sync="openOp" width="80%" :close-on-click-modal="false" append-to-body>
            <dialog-dynamic-op :classesIdSource="defaultClassesId"
                               :sourceDataId="defaultSourceDataId"></dialog-dynamic-op>
            <div slot="footer" class="dialog-footer">
                <el-button @click="openOp = false">取 消</el-button>
            </div>
        </el-dialog>

        <el-dialog title="资源审核" :visible.sync="auditForm.open" width="40%" :close-on-click-modal="false" append-to-body>
            <el-form ref="form" :model="auditForm" label-width="auto" label-position="top">
                <el-form-item label="审核状态" prop="status">
                    <el-select v-model="auditForm.status">
                        <el-option
                            v-for="item in [{label:'通过', value: 1},{label:'拒绝', value: 2}]"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="拒绝说明" prop="description" v-if="auditForm.status === 2">
                    <el-input v-model="auditForm.refuseExplain" type="textarea" placeholder="请输入拒绝说明"/>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="handleAuditSubmit">确 定</el-button>
                <el-button @click="auditForm.open = false">取 消</el-button>
            </div>
        </el-dialog>


    </div>
</template>

<script>
    import * as itemElement from "@/components/BaseControl/itemElement.js"
    import {checkPermi, checkRole} from "@/utils/permission";


    import {
        listDynamic,
        selectField,
        detailsField,
        addDynamic,
        findDynamic,
        editDynamic,
        releaseClasses,
        releaseResource,
        withdrawResource,
        delDynamic,
        auditDynamic,
        dynamicDataUserDepartmentQueryConditions
    } from "@/api/system/dynamic"


    import {
        refreshSingle,
        refreshAll, copyOne
    } from "@/api/business/redis"

    import { listObjectPropertyCount} from "@/api/system/objectProperty";


    import dialogDynamicOp from "./indexOp";

    export default {
        name: "dynamic",
        dicts: ['business_whether'],
        components: {
            dialogDynamicOp,
            ...itemElement,
        },
        data() {
            return {
                imgPathBase: process.env.VUE_APP_BASE_API,
                //关联属性弹窗
                openOp: false,
                // 遮罩层
                loading: true,
                // 导出遮罩层
                exportLoading: false,
                // 导出遮罩层
                releaseLoading: false,
                // 选中数组
                ids: [],
                // 非单个禁用
                single: true,
                // 非多个禁用
                multiple: true,
                // 显示搜索条件
                showSearch: true,
                // 总条数
                total: 0,
                // 动态资源表格数据
                dynamicDataList: [],
                // 字段类型
                dataTypeOptions: [],
                // 字典选项
                dictOptions: [],
                // 弹出层标题
                title: "",
                // 是否显示弹出层
                open: false,
                //查询字段
                selectFieldList: [],
                //展示字段
                showFieldList: [],
                //详情展示字段
                defaultShowFieldDetail: [],
                showFieldDetail: [],
                // 查询参数
                queryParams: {
                    pageNum: 1,
                    pageSize: 10,
                    classesId: null,
                },
                defaultClassesId: null,
                defaultSourceDataId: null,
                // 表单参数
                form: {},
                // 表单校验
                rules: {
                    title: [
                        // { required: true,   message: '请输入名称', trigger: 'blur' },
                        // { validator: this.checkFormRules,  trigger: 'blur' }
                    ]
                },
                objectPropertyListCount: 0,
                //审核
                auditForm: {
                    open: false,
                    ids: [],
                    status: 1,
                    refuseExplain: ''
                },
                //创建人
                createUserList: [],
                //创建人部门
                createDeptList: []
            };
        },
        filters: {
            getDictLabel: function(dictValue, dictDataList) {
                let filter = dictDataList.filter(x=>x.dictValue == dictValue);
                if(filter.length){
                    return filter[0]["dictLabel"]
                }
                return dictValue;
            }
        },
        computed: {},
        created() {
            const classesId = this.$route.params && this.$route.params.classesId;
            this.queryParams.classesId = classesId;
            this.defaultClassesId = classesId;

            listObjectPropertyCount({
                classesId: classesId
            }).then(response => {
                this.objectPropertyListCount = response.count
            });

            dynamicDataUserDepartmentQueryConditions({}).then(response => {
                this.createUserList = response.data.userList.map(item => {
                    return {
                        ...item,
                        value: item.userId,
                        label: item.nickName + "(" + item.deptName + ")"
                    }
                });
                this.createDeptList = response.data.deptList.map(item => {
                    return {
                        ...item,
                        value: item.deptId,
                        label: item.deptName
                    }
                });
            });

            selectField(classesId).then(response => {
                this.selectFieldList = response.data.searchField.map(item => {
                    return {
                        onclickName: 'queryFormChangeVal',
                        ...item
                    }
                });
            });

            detailsField(classesId).then(response => {
                this.showFieldDetail = response.data.detailField.map(item => {
                    return {
                        onclickName: 'formChangeVal',
                        ...item
                    };
                });

                this.defaultShowFieldDetail = this.showFieldDetail;
                this.defaultShowFieldDetail.map(item => {
                    let formValidationRegulation = item.formValidationRegulation;
                    let fieldType = item.fieldType;
                    if (formValidationRegulation) {
                        if (fieldType == "string" || fieldType == "multiple" || fieldType == "richText") {
                            this.rules[item.nameEn] = [{
                                required: true,
                                validator: this.checkFormRules,
                                trigger: 'blur'
                            }]
                        } else {
                            this.rules[item.nameEn] = [{
                                required: true,
                                validator: this.checkFormRules,
                                trigger: ['blur', 'change']
                            }]
                        }
                    }
                });
            });

            this.getList();

        },
        methods: {
            checkPermi,
            checkRole,
            toDataProperty() {
                this.$router.push('/knowledgeBaseManagement/dataProperty/' + this.defaultClassesId)
            },
            checkFormRules(rule, value, callback) {
                value = this.form[rule.field];
                let filterElement = this.defaultShowFieldDetail.filter(x => x.nameEn == rule.field)[0];
                let formValidationRegulation = filterElement.formValidationRegulation;
                let nameZh = filterElement.nameZh;
                let rulesMap = {};
                if (formValidationRegulation) {
                    rulesMap['/^\\S+$/'] = "请输入" + nameZh;
                    let validates = formValidationRegulation.split("|");
                    validates.map(item => {
                        let valudateMsg = item.split("::");
                        if (valudateMsg.length > 1) {
                            rulesMap[valudateMsg[0]] = valudateMsg[1];
                        } else {
                            if (valudateMsg[0] != '*') {
                                rulesMap[valudateMsg[0]] = "请正确输入" + nameZh;
                            }
                        }
                    })
                }
                if (!value) {
                    value = "";
                }
                let verificationResults = true;
                let verificationResultsMsg = "";
                try {
                    Object.keys(rulesMap).map(key => {
                        const re = eval(key);
                        if (re.test(value)) {
                        } else {
                            verificationResults = false;
                            verificationResultsMsg = rulesMap[key];
                            throw new Error("跳出循环");
                        }
                    });
                } catch (e) {
                }
                if (verificationResults) {
                    callback();
                } else {
                    callback(new Error(verificationResultsMsg));
                }
            },
            //==========用于子组件数据传输  START==========
            queryFormChangeVal(msg) {
                Object.keys(msg).forEach(item => {
                    this.queryParams[item] = msg[item];
                })
            },
            formChangeVal(msg) {
                Object.keys(msg).forEach(item => {
                    this.form[item] = msg[item];
                });
            },
            //==========用于子组件数据传输  END==========

            /** 查询公共基础字段列表 */
            getList() {
                this.loading = true;
                listDynamic(this.queryParams).then(response => {
                    this.dynamicDataList = response.data.list;
                    this.total = response.data.total;
                    this.showFieldList = response.data.showField;
                    this.loading = false;
                });
            },
            // 取消按钮
            cancel() {
                this.open = false;
                this.reset();
            },
            // 表单重置
            reset() {
                this.form = {
                    id: null,
                    classesId: null,
                };
                this.resetForm("form");
                this.showFieldDetail = JSON.parse(JSON.stringify(this.defaultShowFieldDetail));
                this.form.classesId = this.defaultClassesId;
            },
            /** 渲染form表单 */
            renderForm() {
                this.showFieldDetail = this.showFieldDetail.map(item => {
                    return {
                        isEdit: true,
                        zhi: this.form[item.nameEn],
                        ...item
                    }
                })
            },
            /** 搜索按钮操作 */
            handleQuery() {
                if (this.queryParams.start_createTime > this.queryParams.end_createTime) {
                    this.$modal.msgWarning("结束时间不能大于开始时间");
                    this.queryParams.start_createTime = '';
                    this.queryParams.end_createTime = '';
                    return;
                }
                this.queryParams.pageNum = 1;
                this.getList();
            },
            /** 重置按钮操作 */
            resetQuery() {
                this.resetForm("queryForm");
                this.$refs[`queryComponentRef`].forEach(item => {
                    item.clearZhi();
                });
                this.handleQuery();
            },
            // 多选框选中数据
            handleSelectionChange(selection) {
                this.ids = selection.map(item => item.id)
                this.single = selection.length !== 1
                this.multiple = !selection.length
            },
            /** 新增按钮操作 */
            handleAdd() {
                this.reset();
                this.open = true;
                this.title = "添加动态资源";
            },
            /** 修改按钮操作 */
            handleUpdate(row) {
                this.reset();
                const id = row.id || this.ids
                findDynamic(this.defaultClassesId, id).then(response => {
                    this.form = response.data;
                    this.form.classesId = this.defaultClassesId;
                    this.renderForm();
                    this.open = true;
                    this.title = "修改动态资源";
                });
            },
            /** 提交按钮 */
            submitForm() {
                this.$refs["form"].validate(valid => {
                    if (valid) {
                        if (this.form.id != null) {
                            editDynamic(this.form).then(response => {
                                this.$modal.msgSuccess("修改成功");
                                this.open = false;
                                this.getList();
                            });
                        } else {
                            addDynamic(this.form).then(response => {
                                this.$modal.msgSuccess("新增成功");
                                this.open = false;
                                this.getList();
                            });
                        }
                        setTimeout(() => {
                            this.handleFlushesAllCaches()
                        }, 1000)
                    } else {
                        this.$modal.msgWarning("请正确完善表单信息")
                    }
                });
            },
            /** 删除按钮操作 */
            handleDelete(row) {
                let idsArr = [];
                if (row.id) {
                    idsArr.push(row.id)
                }
                if (this.ids.length > 0) {
                    idsArr = idsArr.concat(this.ids);
                }
                if (idsArr.length > 0) {
                    const data = {
                        classesId: this.defaultClassesId,
                        ids: idsArr
                    };
                    this.$modal.confirm('是否确认删除动态勾选数据项？').then(function () {
                        return delDynamic(data);
                    }).then(() => {
                        this.getList();
                        this.$modal.msgSuccess("删除成功");
                    }).catch(() => {
                    });
                } else {
                    this.$modal.msgWarning("请选择需要删除的数据项!");
                }

            },
            handleAssociate(row) {
                this.openOp = true;
                this.defaultSourceDataId = row.id;
            },
            handleFlushesSingleCache(row) {
                // defaultClassesId
                let params = {
                    classesId: this.defaultClassesId,
                    id: row.id
                }
                refreshSingle(params).then(response => {
                    this.$modal.msgSuccess("缓存刷新成功");
                });
            },
            copyOne(row) {
                let params = {
                    classesId: this.defaultClassesId,
                    id: row.id
                }
                copyOne(params).then(response => {
                    this.$modal.msgSuccess("复制成功");
                    this.getList();
                }).finally(() => {
                    setTimeout(() => {
                        this.handleFlushesAllCaches()
                    }, 1000)
                });
            },
            handleFlushesAllCaches(row) {
                // defaultClassesId
                let params = {
                    classesId: this.defaultClassesId,
                }
                refreshAll(params).then(response => {
                    this.$modal.msgSuccess("缓存刷新成功");
                });
            },
            //审核
            handleAudit(row) {
                //默认为通过状态
                this.$set(this.auditForm, "status", 1);
                this.$set(this.auditForm, "refuseExplain", '');
                this.$set(this.auditForm, "classesId", this.defaultClassesId);
                let idsArr = [];
                if (row.id) {
                    idsArr.push(row.id)
                }
                if (this.ids.length > 0) {
                    idsArr = idsArr.concat(this.ids);
                }
                if (idsArr.length > 0) {
                    this.auditForm.open = true;
                    this.auditForm.ids = idsArr;
                } else {
                    this.$modal.msgWarning("请选择需要审核的数据项!");
                }
            },
            handleAuditSubmit() {
                if (this.auditForm.status !== 2) {
                    this.auditForm.refuseExplain = '';
                }
                auditDynamic(this.auditForm).then(response => {
                    this.$modal.msgSuccess("审核成功");
                    this.auditForm.open = false;
                    this.getList();
                });
            },
            handleAuditDetail(row) {
                this.$alert(row.refuse_explain, '拒绝理由', {
                    confirmButtonText: '确定',
                    customClass: 'message_box_alert',
                    dangerouslyUseHTMLString: true,
                });
            },
            /** 导出按钮操作 */
            handleExport() {
                this.$modal.msgSuccess("暂未开发");
                // const queryParams = this.queryParams;
                // this.$modal.confirm('是否确认导出所有动态资源数据项？').then(() => {
                //   this.exportLoading = true;
                //   // return exportCommonDataProperty(queryParams);
                // }).then(response => {
                //   this.$download.name(response.msg);
                //   this.exportLoading = false;
                // }).catch(() => {});
            },
            handleRelease(row) {
                let idsArr = [];
                if (row.id) {
                    idsArr.push(row.id)
                }
                if (this.ids.length > 0) {
                    idsArr = idsArr.concat(this.ids);
                }
                if (idsArr.length > 0) {
                    const data = {
                        classesId: this.defaultClassesId,
                        resourceIds: idsArr
                    };
                    this.$modal.confirm('是否确认发布管理数据项？').then(() => {
                        return releaseResource(data)
                    }).then(response => {
                        this.$modal.msgSuccess("发布成功");
                    }).catch(() => {
                    });
                } else {
                    this.$modal.msgWarning("请选择需要发布管理数据项!");
                }
            },
            handleWithdraw(row) {
                let idsArr = [];
                if (row.id) {
                    idsArr.push(row.id)
                }
                if (this.ids.length > 0) {
                    idsArr = idsArr.concat(this.ids);
                }
                if (idsArr.length > 0) {
                    const data = {
                        classesId: this.defaultClassesId,
                        resourceIds: idsArr
                    };
                    this.$modal.confirm('是否确认下撤管理数据项？').then(() => {
                        return withdrawResource(data)
                    }).then(response => {
                        this.$modal.msgSuccess("下撤成功");
                    }).catch(() => {
                    });
                } else {
                    this.$modal.msgWarning("请选择需要下撤管理数据项!");
                }
            },
            handleReleaseAll() {
                const data = {
                    classesIds: this.defaultClassesId,
                };
                this.$modal.confirm('是否确认发布所有数据项？').then(() => {
                    this.releaseLoading = true;
                    return releaseClasses(data)
                }).then(response => {
                    this.releaseLoading = false;
                    this.$modal.msgSuccess("发布成功");
                }).catch(() => {
                });

            }
        }
    };
</script>
<style>
    .el-form-item .el-select {
        width: 100%;
    }

    .el-form--label-top .el-form-item__label {
        padding: 0 !important;
    }

    .el-row {
        margin-bottom: 0px;
    }

    .el-row:last-child {
        margin-bottom: 0;
    }

    .el-col {
        border-radius: 4px;
    }

    .el-form--label-top .el-form-item__label {
        float: none;
        display: inline-block;
        text-align: left;
        padding: 0;
    }

    .col-lg-6 {
        float: left;
        width: 50%;
        padding: 0 10px;
    }

    .col-lg-6 .el-date-editor {
        width: 100%;
    }

    .col-md-12 {
        float: left;
        width: 100%;
        padding: 0 10px;
    }

    .el-dialog__body {
        overflow-y: auto;
    }

    .table-td-thumb {
        display: block;
        margin: auto;
        width: 40px;
        height: 40px;
    }
</style>
